﻿
@{
    ViewBag.Title = "样品登录";
}

<div class="row col-md-12 ml-0" style="height:5vh;display:table-cell;vertical-align:middle">
    <div class="col-3 pr-0" style="display: none">
        <select id="SampleLogin-Person"></select>
        <select id="SampleLogin-Group"></select>
    </div>
    <strong class="font-rfs" style="margin-right: 1rem;">样品登录</strong>
    <button id="SampleLogin-AddSampleDefinition" class="btn btn-rfs" style="padding-top: 0px;"><i class="bi-plus-square"></i> 单样登录</button>
    <button id="SampleLogin-AddSampleGroup" class="btn btn-rfs" style="padding-top: 0px;"><i class="bi-folder-plus"></i> 样品组</button>
    <button id="SampleLogin-DelSampleDefinition" class="btn btn-rfs" style="padding-top: 0px;"><i class="bi-trash"></i> 删除</button>
    <button id="SampleLogin-SetSkipWorkflow" class="btn btn-rfs" style="padding-top: 0px;"><i class="bi-gear"></i> 流程配置</button>
    <button id="SampleLogin-StartSample" class="btn btn-rfs" style="padding-top: 0px;"><i class="bi-caret-right-fill"></i> 开始</button>
    <button id="SampleLogin-SampleBatch" class="btn btn-rfs" style="padding-top: 0px;"><i class="bi-folder-symlink"></i> 样品单</button>
    <button id="SampleLogin-bPrintlab" class="btn btn-rfs" style="padding-top: 0px;"><i class="bi-printer-fill"></i> 标签</button>
</div>
<div class="row col-md-12 ml-0 pre-scrollable" style="min-height:90vh;">
    <div class="row col-md-12" style="padding-right:0px;left: 15px;padding-left: 0px;min-height:40vh;">
        <div class="table-responsive-sm shadow p-0 bg-white rounded col-md-12 pre-scrollable" style="min-height:40vh;">
            <table id="SampleLogin-Table" class="table table-striped table-bordered table-sm table-hover;">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th></th>
                        <th>名称</th>
                        <th>样品ID</th>
                        <th>样品编号</th>
                        <th>批次号</th>
                        <th>样品描述</th>
                        <th>类型</th>
                        <th>分类</th>
                        <th>实验室</th>
                        <th>工作组</th>
                        <th>登录时间</th>
                        <th>采样点</th>
                        <th>指派人</th>
                        <th>指派组</th>
                        <th>附件</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
        </div>
    </div>
    <div class="row col-md-12 ml-0" style="margin-top: 8px; padding-right:0px;padding-left: 0px;min-height:49vh;">
        <div class="row col-md-12 tab-content" style="padding-left: 0;padding-right: 0px;right: -15px;height: 3vh;">
            <ul class="nav col-md-12" style="padding-right: 0;margin-bottom: 1px;">
                <li id="li-tabAnalyte" class="tabButton col-md-1 tab-first-active font-rfs" style="text-align:center;padding-left: 1px;padding-right: 1px;" data-active="true">
                    <a id="a-tabAnalyte" href="#tabAnalyte" data-toggle="tab" class="text-decoration-none" style="display: inline-block;width:100%;">分析项</a>
                </li>
                <li id="li-tabTestDefinition" class="tabButton col-md-1 tab-other-noactive font-rfs" style="text-align: center;padding-left: 1px;padding-right: 1px;" data-active="false">
                    <a id="a-tabTestDefinition" href="#tabTestDefinition" data-toggle="tab" class="text-decoration-none" style="display: inline-block;width:100%;">测试</a>
                </li>
                <li id="li-tabSpecCollection" class="tabButton col-md-1 tab-other-noactive font-rfs" style="text-align: center;padding-left: 1px;padding-right: 1px;" data-active="false">
                    <a id="a-tabSpecCollection" href="#tabSpecCollection" data-toggle="tab" class="text-decoration-none" style="display: inline-block;width:100%;">指标集</a>
                </li>
                <li class="col-md-9 tab-Notactive" style="text-align: center;"><a href="" data-toggle="tab"></a></li>
            </ul>
        </div>
        <div class="row col-md-12 tab-content tab-body" style="padding-right: 0px;right: -15px;padding-left: 0px;top: -2px;min-height:46vh;">
            <div class="col-md-12 ml-0 mr-0 tab-pane active" id="tabAnalyte" style="padding-left: 0px;padding-right: 0px;">
                <div class="row col-md-12" style="min-height:2vh;">
                    <button id="SampleLogin-tabAnalyte-addAnalyte" class="btn btn-rfs"><i class="bi-plus-square"></i> 添加</button>
                    <button id="SampleLogin-tabAnalyte-delAnalyte" class="btn btn-rfs"><i class="bi-trash" onclick=""></i> 删除</button>
                </div>
                <div class="table-responsive-sm p-0 bg-white rounded col-md-12 pre-scrollable" style="min-height:40vh">
                    <table id="SampleLogin-tab-Analyte" class="table table-striped table-bordered table-sm table-hover">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>代码</th>
                                <th>名称</th>
                                <th>分类</th>
                                <th>描述</th>
                                <th>结果模式</th>
                                <th>修约</th>
                                <th>单位</th>
                                <th>默认指标名</th>
                                <th>检测次数</th>
                                <th>报告过滤</th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
            </div>
            <div class="col-md-12 ml-0 mr-0 tab-pane" id="tabTestDefinition" style="padding-left: 0px;padding-right: 0px;">
                <div class="row col-md-6 float-md-left">
                    <div class="row col-md-12" style="min-height:3vh">
                        <button id="SampleLogin-tabTestDefinition-addTD" class="btn btn-rfs"><i class="bi-plus-square"></i> 添加测试</button>
                        <button id="SampleLogin-tabTestDefinition-delTD" class="btn btn-rfs"><i class="bi-trash" onclick=""></i> 删除测试</button>
                        <button id="SampleLogin-tabTestDefinition-delAna" class="btn btn-rfs"><i class="bi-trash" onclick=""></i> 删除分析项</button>
                    </div>
                    <div class="col-md-12 ml-0 mr-0 tab-pane" style="padding-left: 0px;padding-right: 0px;">
                        <div class="table-responsive-sm shadow p-0 bg-white rounded col-md-12 float-md-left pre-scrollable" style="min-height:41vh;">
                            <table id="SampleLogin-tabTestDefinition-TD" class="table table-striped table-bordered table-sm table-hover">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>测试名称</th>
                                        <th>描述</th>
                                        <th>一级分类</th>
                                        <th>二级分类</th>
                                        <th>检测次数</th>
                                        <th>版本</th>
                                    </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="row col-md-6 float-md-left" style="margin-left: 0px;margin-top: 11px;padding-right: 0px;">
                    <div class="row col-md-12" style="padding-right: 0px;margin-right: 0px;right: -15px;padding-left: 0px;height: 3vh;">
                        <ul class="nav col-md-12" style="padding-right: 0;margin-bottom: 1px;">
                            <li id="li-tabTestSpecCollection" class="tabButton col-md-1 tab-first-active font-rfs" style="text-align:center;padding-left: 1px;padding-right: 1px;" data-active="true">
                                <a id="a-tabTestSpecCollection" href="#tabTestSpecCollection" data-toggle="tab" class="text-decoration-none" style="display: inline-block;width:100%;">指标集</a>
                            </li>
                            <li id="li-tabTestMethod" class="tabButton col-md-1 tab-other-noactive font-rfs" style="text-align: center;padding-left: 1px;padding-right: 1px;" data-active="false">
                                <a id="a-tabTestMethod" href="#tabTestMethod" data-toggle="tab" class="text-decoration-none" style="display: inline-block;width:100%;">方法</a>
                            </li>
                            <li class="col-md-10 tab-Notactive" style="text-align: center;"><a href="" data-toggle="tab"></a></li>
                        </ul>
                    </div>
                    <div class="row col-md-12 tab-content tab-body" style="padding-right: 0px;right: -15px;padding-left: 0px;top: -2px;min-height:41vh;">
                        <div class="col-md-12 ml-0 mr-0 tab-pane active pre-scrollable" id="tabTestSpecCollection" style="padding-left: 0px;padding-right: 0px;min-height:31vh">
                            <div class="table-responsive-sm p-0 bg-white rounded col-md-12" style="margin-top: 2px;min-height:41vh;">
                                <table id="tableTestSpecCollection" class="table table-striped table-bordered table-sm table-hover">
                                    <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>默认</th>
                                            <th>代码</th>
                                            <th>名称</th>
                                            <th>描述</th>
                                            <th>一级分类</th>
                                            <th>二级分类</th>
                                            <th>版本</th>
                                            <th>状态</th>
                                        </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </div>
                        </div>
                        <div class="col-md-12 ml-0 mr-0 tab-pane" id="tabTestMethod" style="padding-left: 0px;padding-right: 0px;">
                            <div class="table-responsive-sm p-0 bg-white rounded col-md-12 pre-scrollable" style="margin-top: 2px;min-height:41vh;">
                                <table id="tableTestMethod" class="table table-striped table-bordered table-sm table-hover">
                                    <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>默认</th>
                                            <th>代码</th>
                                            <th>名称</th>
                                            <th>类型</th>
                                            <th>描述</th>
                                            <th>生效日期</th>
                                            <th>有效期至</th>
                                            <th>记录单</th>
                                            <th>版本</th>
                                            <th>状态</th>
                                        </tr>
                                    </thead>
                                    <tbody></tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-12 ml-0 mr-0 tab-pane " id="tabSpecCollection" style="padding-left: 0px;padding-right: 0px;">
                <div class="row col-md-12" style="min-height:2vh;">
                    <button id="SampleLogin-tabSpecCollection-addSpc" class="btn btn-rfs"><i class="bi-plus-square"></i> 添加</button>
                    <button id="SampleLogin-tabSpecCollection-delSpc" class="btn btn-rfs"><i class="bi-trash" onclick=""></i> 删除</button>
                </div>
                <div class="col-md-12 ml-0 mr-0 tab-pane" style="padding-left: 0px;padding-right: 0px;">
                    <div class="table-responsive-sm shadow p-0 bg-white rounded col-md-12 float-md-left pre-scrollable" style="min-height:41vh;">
                        <table id="SampleDefinition-tabSpecList" class="table table-striped table-bordered table-sm table-hover">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>默认</th>
                                    <th>代码</th>
                                    <th>名称</th>
                                    <th>描述</th>
                                    <th>一级分类</th>
                                    <th>二级分类</th>
                                    <th>版本</th>
                                    <th>状态</th>
                                </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal" id="SAMPLE-SampleLogin-Modal" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class='modal-header'>
                <p id="SAMPLE-SampleLogin-Modal-Title" class="pt-3 pl-3 font-rfs"></p>
                <a data-dismiss="modal" class="modal-close">&times;</a>
            </div>
            <div class="modal-body">
                <div id="Embed"></div>
            </div>
        </div>
    </div>
</div>
<div class="modal" id="SAMPLE-SampleLogin-DeleteConfirm" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class='modal-header'>
                <p class="pt-3 pl-3 font-rfs">删除</p>
                <a data-dismiss="modal" class="modal-close">&times;</a>
            </div>
            <div class="modal-body">
                <p class="font-rfs">确认删除当前选中样品吗？</p>
            </div>
            <div class="modal-Delete-footer">
                <button id="modal-delete" class="btn btn-outline-primary border-radius-noradius noLeftBorder noRightBorder font-rfs" style="width:50%; height:fit-content">删除</button>
                <button id="modal-cancel" data-dismiss="modal" class="btn btn-outline-primary border-radius-noradius noRightBorder font-rfs" style="width:50%; height:fit-content">取消</button>
            </div>
        </div>
    </div>
</div>
<div class="modal" id="SampleLogin-DelAnalyteRelation-modal" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class='modal-header'>
                <p class="pt-3 pl-3 font-rfs">删除</p>
                <a data-dismiss="modal" class="modal-close">&times;</a>
            </div>
            <div class="modal-body">
                <p class="font-rfs">确认删除当前分析项吗？</p>
            </div>
            <div class="modal-Delete-footer">
                <button id="SampleLogin-DelAnalyteRelation-modal-delete" class="btn btn-outline-primary border-radius-noradius noLeftBorder noRightBorder font-rfs" style="width:50%; height:fit-content">删除</button>
                <button id="SampleLogin-DelAnalyteRelation-modal-cancel" data-dismiss="modal" class="btn btn-outline-primary border-radius-noradius noRightBorder font-rfs" style="width:50%; height:fit-content">取消</button>
            </div>
        </div>
    </div>
</div>
<div class="modal" id="SampleLogin-DelTestDefinitionRelation-modal" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class='modal-header'>
                <p class="pt-3 pl-3 font-rfs">删除</p>
                <a data-dismiss="modal" class="modal-close">&times;</a>
            </div>
            <div class="modal-body">
                <p class="font-rfs">确认删除当前测试项吗？</p>
            </div>
            <div class="modal-Delete-footer">
                <button id="SampleLogin-DelTestDefinitionRelation-modal-delete" class="btn btn-outline-primary border-radius-noradius noLeftBorder noRightBorder font-rfs" style="width:50%; height:fit-content">删除</button>
                <button id="SampleLogin-DelTestDefinitionRelation-modal-cancel" data-dismiss="modal" class="btn btn-outline-primary border-radius-noradius noRightBorder font-rfs" style="width:50%; height:fit-content">取消</button>
            </div>
        </div>
    </div>
</div>
<div class="modal" id="SampleLogin-DelTestDefinitionRelationAna-modal" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class='modal-header'>
                <p class="pt-3 pl-3 font-rfs">删除</p>
                <a data-dismiss="modal" class="modal-close">&times;</a>
            </div>
            <div class="modal-body">
                <p class="font-rfs">确认删除当前测试中的分析项吗？</p>
            </div>
            <div class="modal-Delete-footer">
                <button id="SampleLogin-DelTestDefinitionRelationAna-modal-delete" class="btn btn-outline-primary border-radius-noradius noLeftBorder noRightBorder font-rfs" style="width:50%; height:fit-content">删除</button>
                <button id="SampleLogin-DelTestDefinitionRelationAna-modal-cancel" data-dismiss="modal" class="btn btn-outline-primary border-radius-noradius noRightBorder font-rfs" style="width:50%; height:fit-content">取消</button>
            </div>
        </div>
    </div>
</div>
<div class="modal" id="SampleLogin-DelSpecCollection-modal" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class='modal-header'>
                <p class="pt-3 pl-3 font-rfs">删除</p>
                <a data-dismiss="modal" class="modal-close">&times;</a>
            </div>
            <div class="modal-body">
                <p class="font-rfs">确认删除当前样品中的指标集吗？</p>
            </div>
            <div class="modal-Delete-footer">
                <button id="SampleLogin-DelSpecCollection-modal-delete" class="btn btn-outline-primary border-radius-noradius noLeftBorder noRightBorder font-rfs" style="width:50%; height:fit-content">删除</button>
                <button id="SampleLogin-DelSpecCollection-modal-cancel" data-dismiss="modal" class="btn btn-outline-primary border-radius-noradius noRightBorder font-rfs" style="width:50%; height:fit-content">取消</button>
            </div>
        </div>
    </div>
</div>
<div class="modal" id="SampleLogin-PrintLab" role="dialog" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class='modal-header'>
                <p id="SampleLogin-PrintLab-Title" class="pt-3 pl-3 font-rfs"></p>
                <a data-dismiss="modal" class="modal-close">&times;</a>
            </div>
            <div class="modal-body">
                <div id="SampleLogin-PrintLab-Embed"></div>
            </div>
        </div>
    </div>
</div>

@section Scripts{
    <script>
        var SampleLogin_Id = "";
        var SampleLogin_refrens = 0;  /*是否刷新登录样品绑定table指示器*/
        var SampleLogin_AnalyteId = "";
        var SampleLogin_TestDefinitonId = "";
        var SampleLogin_TD_AnalyteId = "";
        var SampleLogin_SpecCollectionId = "";

        $(document).ready(function () {
            LoadSampleLogin();
            LoadUsers('SampleLogin-Person');
            LoadAllGroupList('SampleLogin-Group');
        });

        function SetSampleNumber(value, row, index) {
            var text = value == null ? '' : value;
            var strHtml = "<input class='table-cell-input' data-Id=" + row.id + "  onchange='UpdateSampleNumber(this)'  onclick='stopPropagation(event)' value='" + text + "'/>";
            return strHtml;
        }

        function SetBatchId(value, row, index) {
            var text = value == null ? '' : value;
            var strHtml = "<input class='table-cell-input' data-Id=" + row.id + "  onchange='UpdateBatchId(this)'  onclick='stopPropagation(event)' value='" + text + "'/>";
            return strHtml;
        }

        function UpdateSampleNumber(obj) {
            var st = $(obj).val();
            if (st.length > 50)
                alert("字符串长度不能超过50，多出部分将自动被截取！");

            $.post("postUpdateSampleLoginSampleNumber", {
                Id: $(obj.outerHTML).attr("data-Id"),
                SampleNumber: st
            }, function (data) {
                if (data.indexOf("成功") <= 0) {
                    alert(data);
                }
            });
        }

        function UpdateBatchId(obj) {
            var st = $(obj).val();
            if (st.length > 50)
                alert("字符串长度不能超过50，多出部分将自动被截取！");

            $.post("postUpdateSampleLoginBatchId", {
                Id: $(obj.outerHTML).attr("data-Id"),
                BatchId: st
            },  function (data) {
                if (data.indexOf("成功") <= 0) {
                    alert(data);
                }
            });
        }
        
        function stopPropagation(event) {
            event.stopPropagation();
        }

        function setLoginTime(value, row, index) {
            return row.loginTime.replace('T',' ');
        }

        function setAttachment(value, row, index) {
            var strHtml = "<button class='table-cell-button btn-rfs' data-Method-Id=" + row.id + " onclick='TableCellButton(this)'><i class='bi-tools' title='附件管理'></i></button>";
            return strHtml;
        }

        function TableCellButton(obj) {
            $("#SAMPLE-SampleLogin-Modal-Title").text("样品附件管理");

            $("#SAMPLE-SampleLogin-Modal").modal({
                backdrop: 'static',
                keyboard: false
            });

            $.post("/Common/ManageFile", {
                Domain: "Sample",
                DomainId: $(obj).parent().parent().attr('data-uniqueid'),
                ModalID: "SAMPLE-SampleLogin-Modal"
            }, function (datas) {
                $("#Embed").html(datas);
            });
            event.stopPropagation();
        }

        function LoadSampleLogin() {
            SampleLogin_Id = "";  /*清空该值*/
            SampleLogin_refrens = 0;
            $('#SampleLogin-Table').bootstrapTable('destroy'); // 这行代码必须加，否则数据无法刷新
            var columns = [{ field: "id", visible: false }, { field: "selectItem", width: "5%", align: "center", checkbox:true }, { field: "name" },
            { field: "sampleId" }, { field: "sampleNumber", formatter: SetSampleNumber }, { field: "batchId", formatter: SetBatchId }, { field: "description" },
            { field: "classification" }, { field: "genricClass" }, { field: "site" }, { field: "group" }, { field: "loginTime", formatter: setLoginTime },
            { field: "samplingPoint" }, { field: "assignPersonName", formatter: SetPerson }, { field: "assignGroupName", formatter: SetGroup }, 
            { field: "sopFiles", width: "5%", formatter: setAttachment }];

            $('#SampleLogin-Table').bootstrapTable({
                method: 'post',
                url: "GetSampleLoginList",
                dataType: "json",  // 服务器端返回值类型
                contentType: "application/x-www-form-urlencoded; charset=UTF-8", // 如果是 POST 请求，这个属性必须加
                queryParams: function (params) {
                    var data = {
                        limit:params.limit, // 每页显示多少条记录
                        offset:params.offset // 偏移量
                    };
                    return data;
                },
                queryParamsType: "limit", // 服务器端分页，这个参数必需是“limit”
                dataField:"rows",

                uniqueId: "id",          // 设置主键
                sidePagination: "server", // 服务器端分页，这个参数必需设置
                pagination: true,  // 显示分页条,设为true，启用了分页功能
                pageNumber: 1,
                pageSize: 20,   // 默认页大小
                pageList: [10, 20, 50, 100],  // 控制每页数目
                locale: "zh-CN",
                columns: columns,          // 加载列定义, 注意！这个地方绑定的列名称开头大写字母会全部变成小写。

                selectItemName: "selectItem", // 指定选择行ID
                clickToSelect:true, // 相应单击，自动选中此行
                checkboxHeader:true, // 标题行显示全选按钮

                onClickRow: function (row, $element, field) {
                    $("#SampleLogin-Table").find("tbody").find("tr").each(function () {
                        $(this).removeClass('changeblueColor');
                    });
                    $element.addClass("changeblueColor");
                    SampleLogin_Id = row.id;
                    LoadAnalyte(SampleLogin_Id);
                    LoadTestDefinition(SampleLogin_Id);
                    LoadSpecCollection(SampleLogin_Id);
                },
                silent: true,  //刷新事件必须设置
                formatLoadingMessage: function () {
                    return "请稍等，正在加载中...";
                },
                formatNoMatches: function () {  //没有匹配的结果
                    return '无符合条件的记录';
                },
                onLoadError: function (data) {
                    $('#SampleLogin-Table').bootstrapTable('removeAll');
                },
                onLoadSuccess: function (data) {   // 数据加载成功后触发该事件
                    SetBootstrapStyle();
                },
                formatShowingRows: function (pageFrom, pageTo, totalRows) {
                    return "正在显示第" + pageFrom + "到第" + pageTo + "条记录，总共" + totalRows + "条记录 ";
                },
                formatRecordsPerPage: function (pageNumber) {
                    return " 每页显示" + pageNumber + '条记录';
                }
            });
        }

        function SetPerson(value, row, index) {
            var strHtml = "<select class='table-cell-select' onchange='UpdateAssignPerson(this)'>";
            var array = $('#SampleLogin-Person option').toArray();
            $(array).each(function () {
                if (value == $(this).html()) {
                    strHtml = strHtml + "<option value='" + $(this).val() + "' selected='true'>" + $(this).html() + "</option>";
                } else {
                    strHtml = strHtml + "<option value='" + $(this).val() + "'>" + $(this).html() + "</option>";
                }
            })
            return strHtml + "</select>";
        }

        function SetGroup(value, row, index) {
            var strHtml = "<select class='table-cell-select' onchange='UpdateAssignGroup(this)'>";
            var array = $('#SampleLogin-Group option').toArray();
            $(array).each(function () {
                if (value == $(this).html()) {
                    strHtml = strHtml + "<option value='" + $(this).val() + "' selected='true'>" + $(this).html() + "</option>";
                } else {
                    strHtml = strHtml + "<option value='" + $(this).val() + "'>" + $(this).html() + "</option>";
                }
            })
            return strHtml + "</select>";
        }

        function UpdateAssignPerson(obj) {
            var st = $(obj).prop("checked");
            var rowid = $(obj).parent().parent().attr('data-uniqueid');

            $.post("UpdateAssignPerson", {
                Id: rowid,
                PersonId: $(obj).val(),
                PersonName: $(obj).find("option:selected").text()
            }, function (data) {
                //alert(data);
            });
        }

        function UpdateAssignGroup(obj) {
            var st = $(obj).prop("checked");
            var rowid = $(obj).parent().parent().attr('data-uniqueid');

            $.post("UpdateAssignGroup", {
                Id: rowid,
                GroupId: $(obj).val(),
                GroupName: $(obj).find("option:selected").text()
            }, function (data) {
                //alert(data);
            });
        }

        function ReleaseOnClick(obj) {
            var st = $(obj).prop("checked");
            var rowid = $(obj).attr("data-rowid");

            $.post("UpdateSampleLoginIsRelease", {
                SampleLoginId: rowid,
                IsRelease: st
            }, function (data) {
                if (data.indexOf("成功") < 0) {
                    alert(data);
                }
            });
        }

        function SetDetectionTimes(value, row, index) {
            var text = value == null ? '-' : value;
            var strHtml = "<input class='table-cell-input' data-Id=" + row.id + "  onchange='UpdateDetectionTimes(this)' value='" + text + "' style='text-align: center;'/>";
            return strHtml;
        }

        function UpdateDetectionTimes(obj) {
            var st = $(obj).val();
            $.post("postUpdateSampleLoginDetectionTimes", {
                Id: $(obj.outerHTML).attr("data-Id"),
                DetectionTimes: st
            },  function (data) {
                if (data.indexOf("成功") <= 0) {
                    alert(data);
                }
            });
        }

        function LoadAnalyte(SampleLogin_Id) { 
            SampleLogin_AnalyteId = "";
            var columns = [{ field: "id", visible: false }, { field: "code" }, { field: "name" }, { field: "classification" }, { field: "description"},
            { field: "resultModel" }, { field: "roundingOff" }, { field: "units" }, { field: "defaultSpecName" },
            { field: "detectionTimes", width: "5%", formatter: SetDetectionTimes }, { field: "assist" }];

            $('#SampleLogin-tab-Analyte').bootstrapTable('destroy');
            $('#SampleLogin-tab-Analyte').bootstrapTable({
                method: 'post',
                url: "GetSampleLoginRelationAnalytes",
                dataType: "json",  // 服务器端返回值类型
                contentType: "application/x-www-form-urlencoded; charset=UTF-8", // 如果是 POST 请求，这个属性必须加
                queryParams: function (params) {
                    var data = {
                        SampleId: SampleLogin_Id,  // 传递的参数，这的名称要和控制器里对应的参数名称一样
                    };
                    return data;
                }, //参数
                queryParamsType: "search", //参数格式,发送标准的RESTFul类型的参数请求

                uniqueId: "id",          // 设置主键
                locale: "zh-CN",
                columns: columns,          // 加载列定义, 注意！这个地方绑定的列名称开头大写字母会全部变成小写。
                onClickRow: function (row, $element, field) {
                    $("#SampleLogin-tab-Analyte").find("tbody").find("tr").each(function () {
                        $(this).removeClass('changeblueColor');
                    });
                    $element.addClass("changeblueColor");
                    SampleLogin_AnalyteId = row.id;
                },
                silent: true,  //刷新事件必须设置
                formatLoadingMessage: function () {
                    return "请稍等，正在加载中...";
                },
                formatNoMatches: function () {  //没有匹配的结果
                    $('.fixed-table-toolbar').css("height", "0px"); /* 隐藏表格上的工具栏 */
                    return '无符合条件的记录';
                },
                onLoadError: function (data) {
                    $('#Analyte').bootstrapTable('removeAll');
                },
                onLoadSuccess: function (data) {   // 数据加载成功后触发该事件
                    SetBootstrapStyle();
                }
            });
        }

        function InitSubTable(index, row, $detail) {
            var subtable = $detail.html('<table></table>').find('table');
            var columns = [{ field: "id", visible: false }, { field: "code", title: "代码" }, { field: "name", title: "名称" },
            { field: "classification", title: "分类" }, { field: "description", title: "描述" }, { field: "resultModel", title: "结果模式" },
            { field: "roundingOff", title: "修约" }, { field: "units", title: "单位" }, { field: "defaultSpecName", title: "默认指标" }, 
            { field: "assist", title: "报告过滤" },{ field: "detectionTimes", width: "5%", title: "检测次数", formatter: SetDetectionTimes }];

            $(subtable).bootstrapTable({
                method: 'post',
                url: "GetTestDifinitonAnalytesByLoginRelationId",
                dataType: "json",  // 服务器端返回值类型
                contentType: "application/x-www-form-urlencoded; charset=UTF-8", // 如果是 POST 请求，这个属性必须加
                queryParams: function (params) {
                    var data = {
                        RelationId: row.id
                    };
                    return data;
                }, //参数
                queryParamsType: "search", //参数格式,发送标准的RESTFul类型的参数请求

                uniqueId: "id",          // 设置主键
                locale: "zh-CN",
                columns: columns,          // 加载列定义, 注意！这个地方绑定的列名称开头大写字母会全部变成小写。
                onClickRow: function (row, $element, field) {
                    $(subtable).find("tbody").find("tr").each(function () {
                        $(this).removeClass('changeblueColor');
                    });
                    $element.addClass("changeblueColor");
                    SampleLogin_TD_AnalyteId = row.id;
                },
                silent: true,  //刷新事件必须设置

                formatLoadingMessage: function () {
                    return "请稍等，正在加载中...";
                },
                formatNoMatches: function () {  //没有匹配的结果
                    return '无符合条件的记录';
                },
                onLoadError: function (data) {
                    $(subtable).bootstrapTable('removeAll');
                },
                onLoadSuccess: function (data) {   // 数据加载成功后触发该事件
                    SetBootstrapStyle();
                }
            });
        }

        function LoadTestDefinition(SampleLogin_Id) {
            SampleLogin_TestDefinitonId = "";  /*清空该值*/
            $('#SampleLogin-tabTestDefinition-TD').bootstrapTable('destroy'); // 这行代码必须加，否则数据无法刷新
            var columns = [{ field: "id", visible: false }, { field: "testName", width: "10%", align: "center" }, 
            { field: "description", align: "left" },{ field: "firstGroup", align: "left" },
            { field: "secondGroup", align: "left" }, { field: "detectionTimes", width: "5%", formatter: SetDetectionTimes },
            { field: "version", width:"5%", align:"center" }];

            $('#SampleLogin-tabTestDefinition-TD').bootstrapTable({
                method: 'post',
                url: "GetSampleLoginRelationTestDefinition",
                dataType: "json",  // 服务器端返回值类型
                contentType: "application/x-www-form-urlencoded; charset=UTF-8", // 如果是 POST 请求，这个属性必须加
                queryParams: function (params) {
                    var data = {
                        SampleId: SampleLogin_Id  // 传递的参数，这的名称要和控制器里对应的参数名称一样
                    };
                    return data;
                }, //参数
                queryParamsType: "search", //参数格式,发送标准的RESTFul类型的参数请求

                uniqueId: "id",
                locale: "zh-CN",
                columns: columns,
                onClickRow: function (row, $element, field) {
                    $("#SampleLogin-tabTestDefinition-TD").find("tbody").find("tr").each(function () {
                        $(this).removeClass('changeblueColor');
                    });
                    $element.addClass("changeblueColor");
                    SampleLogin_TestDefinitonId = row.id;
                    LoadTestDefinitionMethod(SampleLogin_TestDefinitonId);
                    LoadTestDefinitionSpecCollection(SampleLogin_TestDefinitonId);
                },
                silent: true,  //刷新事件必须设置

                detailView: true,  // 详细视图必须设置该项
                icons:{  // 设置详细视图的图标
                    detailOpen: 'bi-plus',
                    detailClose: 'bi-dash'
                },
                onExpandRow: function (index, row, $detail) {  // 单击展开视图时触发的函数
                     InitSubTable(index, row, $detail);
                },

                formatLoadingMessage: function () {
                    return "请稍等，正在加载中...";
                },
                formatNoMatches: function () {  //没有匹配的结果
                    return '无符合条件的记录';
                },
                onLoadError: function (data) {
                    $('#SampleLogin-tabTestDefinition-TD').bootstrapTable('removeAll');
                },
                onLoadSuccess: function (data) {   // 数据加载成功后触发该事件
                    SetBootstrapStyle();
                }
            });

            $('#SampleLogin-tabTestDefinition-Analyte').bootstrapTable('removeAll');
        }

        function SetMethodIsDefault(value, row, index) {
            var strHtml = "";
            if (row.isDefault) {
                strHtml = "<input type='checkbox' checked onclick='UpdateRelationMethodIsDefault(this)' data-rowid='" + row.id + "'/>";
            } else {
                strHtml = "<input type='checkbox' onclick='UpdateRelationMethodIsDefault(this)' data-rowid='" + row.id + "'/>";
            }

            return strHtml;
        }

        function UpdateRelationMethodIsDefault(obj) {
            var rowid = $(obj).attr("data-rowid");

            $.post("UpdateRelationMethodIsDefault", {
                Id: rowid
            }, function (data) {
                if (data.indexOf("成功") >= 0) {
                    LoadTestDefinitionMethod(SampleLogin_TestDefinitonId);
                } else {
                    alert(data);
                }
            });
        }

        function setEffectiveDate(value, row, index) {
            if (!row.effectiveDate) {
                return '';
            } else {
                return row.effectiveDate.split('T')[0];
            }
        }

        function setExpireDate(value, row, index) {
            if (!row.expireDate) {
                return '';
            } else {
                return row.expireDate.split('T')[0];
            }
        }

        function LoadTestDefinitionMethod(SampleLogin_TestDefinitonId) {
            var columns = [{ field: "id", visible: false }, { field: "isDefault", width: "5%", align: "center", formatter: SetMethodIsDefault },
            { field: "code" }, { field: "name" }, { field: "type" }, { field: "description" },
            { field: "effectiveDate", formatter: setEffectiveDate }, { field: "expireDate", formatter: setExpireDate }, { field: "recordSheet" },
            { field: "version", width: "5%", }, { field: "status", width: "5%", }];

            $('#tableTestMethod').bootstrapTable('destroy'); // 这行代码必须加，否则数据无法刷新
            $('#tableTestMethod').bootstrapTable({
                method: 'post',
                url: "GetSampleLoginRelationMethod",
                dataType: "json",  // 服务器端返回值类型
                contentType: "application/x-www-form-urlencoded; charset=UTF-8", // 如果是 POST 请求，这个属性必须加
                queryParams: function (params) {
                    var data = {
                        TestId: SampleLogin_TestDefinitonId,  // 传递的参数，这的名称要和控制器里对应的参数名称一样
                    };
                    return data;
                }, //参数
                queryParamsType: "search", //参数格式,发送标准的RESTFul类型的参数请求

                uniqueId: "id",          // 设置主键
                locale: "zh-CN",
                columns: columns,          // 加载列定义, 注意！这个地方绑定的列名称开头大写字母会全部变成小写。
                onClickRow: function (row, $element, field) {
                    $("#tableTestMethod").find("tbody").find("tr").each(function () {
                        $(this).removeClass('changeblueColor');
                    });
                    $element.addClass("changeblueColor");
                },
                silent: true,  //刷新事件必须设置
                formatLoadingMessage: function () {
                    return "请稍等，正在加载中...";
                },
                formatNoMatches: function () {  //没有匹配的结果
                    return '无符合条件的记录';
                },
                onLoadError: function (data) {
                    $('#tableTestMethod').bootstrapTable('removeAll');
                },
                onLoadSuccess: function (data) {   // 数据加载成功后触发该事件
                    SetBootstrapStyle();
                },
                formatShowingRows: function (pageFrom, pageTo, totalRows) {
                    return "正在显示第" + pageFrom + "到第" + pageTo + "条记录，总共" + totalRows + "条记录 ";
                },
                formatRecordsPerPage: function (pageNumber) {
                    return " 每页显示" + pageNumber + '条记录';
                }
            });
        }

        function SetSpecCollectionIsDefault(value, row, index) {
            var strHtml = "";
            if (row.isDefault) {
                strHtml = "<input type='checkbox' checked onclick='UpdateRelationSpecCollectionIsDefault(this)' data-rowid='" + row.id + "'/>";
            } else {
                strHtml = "<input type='checkbox' onclick='UpdateRelationSpecCollectionIsDefault(this)' data-rowid='" + row.id + "'/>";
            }

            return strHtml;
        }

        function UpdateRelationSpecCollectionIsDefault(obj) {
            var rowid = $(obj).attr("data-rowid");

            $.post("UpdateRelationSpecCollectionIsDefault", {
                Id: rowid,
            }, function (data) {
                if (data.indexOf("成功") >= 0) {
                    LoadTestDefinitionSpecCollection(SampleLogin_TestDefinitonId);
                } else {
                    alert(data);
                }
            });
        }

        function LoadTestDefinitionSpecCollection(SampleLogin_TestDefinitonId) {
            var columns = [{ field: "id", visible: false }, { field: "isDefault", width: "5%", align: "center", formatter: SetSpecCollectionIsDefault },
            { field: "code" }, { field: "name" }, { field: "description" },
            { field: "firstGroup" }, { field: "secondGroup" }, { field: "version" }, { field: "releaseStatus" }];

            $('#tableTestSpecCollection').bootstrapTable('destroy'); // 这行代码必须加，否则数据无法刷新
            $('#tableTestSpecCollection').bootstrapTable({
                method: 'post',
                url: "GetSampleLoginRelationSpecCollection",
                dataType: "json",  // 服务器端返回值类型
                contentType: "application/x-www-form-urlencoded; charset=UTF-8", // 如果是 POST 请求，这个属性必须加
                queryParams: function (params) {
                    var data = {
                        TestId: SampleLogin_TestDefinitonId,  // 传递的参数，这的名称要和控制器里对应的参数名称一样
                    };
                    return data;
                }, //参数
                queryParamsType: "search", //参数格式,发送标准的RESTFul类型的参数请求

                uniqueId: "id",          // 设置主键
                locale: "zh-CN",
                columns: columns,          // 加载列定义, 注意！这个地方绑定的列名称开头大写字母会全部变成小写。
                onClickRow: function (row, $element, field) {
                    $("#tableTestSpecCollection").find("tbody").find("tr").each(function () {
                        $(this).removeClass('changeblueColor');
                    });
                    $element.addClass("changeblueColor");
                },
                silent: true,  //刷新事件必须设置

                detailView: true,  // 详细视图必须设置该项
                icons: {  // 设置详细视图的图标
                    detailOpen: 'bi-plus',
                    detailClose: 'bi-dash'
                },
                onExpandRow: function (index, row, $detail) {  // 单击展开视图时触发的函数
                    InitTestSpecCollection(index, row, $detail);
                },

                formatLoadingMessage: function () {
                    return "请稍等，正在加载中...";
                },
                formatNoMatches: function () {  //没有匹配的结果
                    return '无符合条件的记录';
                },
                onLoadError: function (data) {
                    $('#Analyte').bootstrapTable('removeAll');
                },
                onLoadSuccess: function (data) {   // 数据加载成功后触发该事件
                    SetBootstrapStyle();
                },
                formatShowingRows: function (pageFrom, pageTo, totalRows) {
                    return "正在显示第" + pageFrom + "到第" + pageTo + "条记录，总共" + totalRows + "条记录 ";
                },
                formatRecordsPerPage: function (pageNumber) {
                    return " 每页显示" + pageNumber + '条记录';
                }
            });
        }

        function InitTestSpecCollection(index, row, $detail) {
            var subtable = $detail.html('<table></table>').find('table');
            var columns = [{ field: "id", visible: false }, { field: "code", title: "代码" }, { field: "name", title: "名称" },
            { field: "classification", title: "分类" }, { field: "description", title: "描述" }, { field: "resultModel", title: "结果模式" },
            { field: "roundingOff", title: "修约" }, { field: "units", title: "单位" }, { field: "lowA", title: "lowA" },
            { field: "lowB", title: "lowB" }, { field: "highB", title: "highB" }, { field: "highA", title: "highA" },
            { field: "acceptanceCriteria", title: "验收标准" }];

            $(subtable).bootstrapTable({
                method: 'post',
                url: "GetSpecCollectionAnalytesBySampleLoginRelation",
                dataType: "json",  // 服务器端返回值类型
                contentType: "application/x-www-form-urlencoded; charset=UTF-8", // 如果是 POST 请求，这个属性必须加
                queryParams: function (params) {
                    var data = {
                        LoginRelationId: row.id,  // 传递的参数，这的名称要和控制器里对应的参数名称一样
                    };
                    return data;
                }, //参数
                queryParamsType: "search", //参数格式,发送标准的RESTFul类型的参数请求

                uniqueId: "id",          // 设置主键
                locale: "zh-CN",
                columns: columns,          // 加载列定义, 注意！这个地方绑定的列名称开头大写字母会全部变成小写。
                onClickRow: function (row, $element, field) {
                    $(subtable).find("tbody").find("tr").each(function () {
                        $(this).removeClass('changeblueColor');
                    });
                    $element.addClass("changeblueColor");
                },
                silent: true,  //刷新事件必须设置
                formatLoadingMessage: function () {
                    return "请稍等，正在加载中...";
                },
                formatNoMatches: function () {  //没有匹配的结果
                    return '无符合条件的记录';
                },
                onLoadError: function (data) {
                    $(subtable).bootstrapTable('removeAll');
                },
                onLoadSuccess: function (data) {   // 数据加载成功后触发该事件
                    SetBootstrapStyle();
                },
                formatShowingRows: function (pageFrom, pageTo, totalRows) {
                    return "正在显示第" + pageFrom + "到第" + pageTo + "条记录，总共" + totalRows + "条记录 ";
                },
                formatRecordsPerPage: function (pageNumber) {
                    return " 每页显示" + pageNumber + '条记录';
                }
            });
        }

        function SetSampleSpecCollectionIsDefault(value, row, index) {
            var strHtml = "";
            if (row.isDefault == 1) {
                strHtml = "<input type='checkbox' checked onclick='UpdateSampleSpecCollectionIsDefault(this)' data-rowid='" + row.id + "'/>";
            } else {
                strHtml = "<input type='checkbox' onclick='UpdateSampleSpecCollectionIsDefault(this)' data-rowid='" + row.id + "'/>";
            }

            return strHtml;
        }

        function UpdateSampleSpecCollectionIsDefault(obj) {
            var rowid = $(obj).attr("data-rowid");

            $.post("UpdateRelationSampleSpecIsDefault", {
                Id: rowid
            }, function (data) {
                if (data.indexOf("成功") >= 0) {
                    LoadSpecCollection(SampleLogin_Id);
                } else {
                    alert(data);
                }
            });
        }

        function InitSampleSpecCollection(index, row, $detail) {
            var subtable = $detail.html('<table></table>').find('table');
            var columns = [{ field: "id", visible: false }, { field: "code", title: "代码" }, { field: "name", title: "名称" },
            { field: "classification", title: "分类" }, { field: "description", title: "描述" }, { field: "resultModel", title: "结果模式" },
            { field: "roundingOff", title: "修约" }, { field: "units", title: "单位" }, { field: "lowA", title: "lowA" },
            { field: "lowB", title: "lowB" }, { field: "highB", title: "highB" }, { field: "highA", title: "highA" },
            { field: "acceptanceCriteria", title: "验收标准" }];

            $(subtable).bootstrapTable({
                method: 'post',
                url: "GetSpecCollectionAnalytesByLoginRelationId",
                dataType: "json",  // 服务器端返回值类型
                contentType: "application/x-www-form-urlencoded; charset=UTF-8", // 如果是 POST 请求，这个属性必须加
                queryParams: function (params) {
                    var data = {
                        LoginRelationId: row.id,
                    };
                    return data;
                }, //参数
                queryParamsType: "search", //参数格式,发送标准的RESTFul类型的参数请求

                uniqueId: "id",          // 设置主键
                locale: "zh-CN",
                columns: columns,          // 加载列定义, 注意！这个地方绑定的列名称开头大写字母会全部变成小写。
                onClickRow: function (row, $element, field) {
                    $(subtable).find("tbody").find("tr").each(function () {
                        $(this).removeClass('changeblueColor');
                    });
                    $element.addClass("changeblueColor");
                },
                silent: true,  //刷新事件必须设置
                formatLoadingMessage: function () {
                    return "请稍等，正在加载中...";
                },
                formatNoMatches: function () {  //没有匹配的结果
                    return '无符合条件的记录';
                },
                onLoadError: function (data) {
                    $(subtable).bootstrapTable('removeAll');
                },
                onLoadSuccess: function (data) {   // 数据加载成功后触发该事件
                    SetBootstrapStyle();
                },
                formatShowingRows: function (pageFrom, pageTo, totalRows) {
                    return "正在显示第" + pageFrom + "到第" + pageTo + "条记录，总共" + totalRows + "条记录 ";
                },
                formatRecordsPerPage: function (pageNumber) {
                    return " 每页显示" + pageNumber + '条记录';
                }
            });
        }

        function LoadSpecCollection(SampleId) {
            SampleLogin_SpecCollectionId = "";
            var columns = [{ field: "id", visible: false }, { field: "isDefault", width: "5%", align: "center", formatter: SetSampleSpecCollectionIsDefault },
            { field: "code" }, { field: "name" }, { field: "description" },
            { field: "firstGroup" }, { field: "secondGroup" }, { field: "version" }, { field: "releaseStatus" }];

            $('#SampleDefinition-tabSpecList').bootstrapTable('destroy'); // 这行代码必须加，否则数据无法刷新
            $('#SampleDefinition-tabSpecList').bootstrapTable({
                method: 'post',
                url: "GetSampleLoginSpecCollection",
                dataType: "json",  // 服务器端返回值类型
                contentType: "application/x-www-form-urlencoded; charset=UTF-8", // 如果是 POST 请求，这个属性必须加
                queryParams: function (params) {
                    var data = {
                        SampleId: SampleId,
                    };
                    return data;
                }, //参数
                queryParamsType: "search", //参数格式,发送标准的RESTFul类型的参数请求

                uniqueId: "id",          // 设置主键
                locale: "zh-CN",
                columns: columns,          // 加载列定义, 注意！这个地方绑定的列名称开头大写字母会全部变成小写。
                onClickRow: function (row, $element, field) {
                    $("#SampleDefinition-tabSpecList").find("tbody").find("tr").each(function () {
                        $(this).removeClass('changeblueColor');
                    });
                    $element.addClass("changeblueColor");
                    SampleLogin_SpecCollectionId = row.id;
                },
                silent: true,  //刷新事件必须设置

                detailView: true,  // 详细视图必须设置该项
                icons: {  // 设置详细视图的图标
                    detailOpen: 'bi-plus',
                    detailClose: 'bi-dash'
                },
                onExpandRow: function (index, row, $detail) {  // 单击展开视图时触发的函数
                    InitSampleSpecCollection(index, row, $detail);
                },

                formatLoadingMessage: function () {
                    return "请稍等，正在加载中...";
                },
                formatNoMatches: function () {  //没有匹配的结果
                    return '无符合条件的记录';
                },
                onLoadError: function (data) {
                    $('#Analyte').bootstrapTable('removeAll');
                },
                onLoadSuccess: function (data) {   // 数据加载成功后触发该事件
                    SetBootstrapStyle();
                },
                formatShowingRows: function (pageFrom, pageTo, totalRows) {
                    return "正在显示第" + pageFrom + "到第" + pageTo + "条记录，总共" + totalRows + "条记录 ";
                },
                formatRecordsPerPage: function (pageNumber) {
                    return " 每页显示" + pageNumber + '条记录';
                }
            });
        }

        function GetSelectItems() {
            var rows = $('#SampleLogin-Table').bootstrapTable('getSelections');
            if (rows.length == 0) {
                return;
            } else {
                var arrays = new Array();
                $(rows).each(function() {
                    arrays.push(this.id);
                })

                var ids = arrays.join(',');
                return ids;
            }
        }

        $("#SampleLogin-DelSampleDefinition").click(function () {
            var ids = GetSelectItems("SampleLogin-Table");
            if (ids.length == 0) {
                return false;
            }

            $("#SAMPLE-SampleLogin-DeleteConfirm").modal({
                backdrop: 'static',
                keyboard: false
            });
        });

        $("#modal-delete").click(function () {
            var ids = GetSelectItems("SampleLogin-Table");
            
            $.post("postDeleteSampleLogin", {
                Ids: ids
            }, function (data) {
                if (data.indexOf("成功") >= 0) {
                    LoadSampleLogin();
                    $('#SampleLogin-tab-Analyte').bootstrapTable('removeAll');
                    $('#SampleLogin-tabTestDefinition-TD').bootstrapTable('removeAll');
                    $('#tableTestSpecCollection').bootstrapTable('removeAll');
                    $('#tableTestMethod').bootstrapTable('removeAll');
                    $('#SampleDefinition-tabSpecList').bootstrapTable('removeAll');
                } else {
                    alert(data);
                }
            });

            $("#SAMPLE-SampleLogin-DeleteConfirm").modal('hide');
        });

        $("#SampleLogin-DelAnalyteRelation-modal-delete").click(function () {
            $.post("DelteSampleLoginRelationById", {
                Id: SampleLogin_AnalyteId
            }, function (data) {
                if (data.indexOf("成功") >= 0) {
                    $('#SampleLogin-tab-Analyte').bootstrapTable('removeByUniqueId', SampleLogin_AnalyteId);  // 删除指定的行
                    SampleLogin_AnalyteId = "";  // 删除行后，将这个值置空，否则直接编辑信息就会报错。
                } else {
                    alert(data);
                }
            });

            $("#SampleLogin-DelAnalyteRelation-modal").modal('hide');
        });

        $("#SampleLogin-AddSampleDefinition").click(function () {
            SampleLogin_refrens = 1;
            $("#SAMPLE-SampleLogin-Modal-Title").text("登录样品");

            $("#SAMPLE-SampleLogin-Modal").modal({
                backdrop: 'static',
                keyboard: false
            });

            $.post("SelectSampleDefinition", {
                ModalID: "SAMPLE-SampleLogin-Modal"
            }, function (datas) {
                $("#Embed").html(datas);
            });
        });

        $("#SampleLogin-AddSampleGroup").click(function () {
            SampleLogin_refrens = 1;
            $("#SAMPLE-SampleLogin-Modal-Title").text("登录样品组");

            $("#SAMPLE-SampleLogin-Modal").modal({
                backdrop: 'static',
                keyboard: false
            });

            $.post("SelectSampleGroup", {
                ModalID: "SAMPLE-SampleLogin-Modal"
            }, function (datas) {
                $("#Embed").html(datas);
            });
        });

        $("#SampleLogin-SampleBatch").click(function () {
            $("#SAMPLE-SampleLogin-Modal-Title").text("绑定样品单");

            $("#SAMPLE-SampleLogin-Modal").modal({
                backdrop: 'static',
                keyboard: false
            });

            var row = $("#SampleLogin-Table").bootstrapTable('getRowByUniqueId', GetSelectIdByColor('SampleLogin-Table'));
            $.post("SampleBatch", {
                ModalID: "SAMPLE-SampleLogin-Modal",
                SampleBatchId: row == null ? null : row.batchId
            }, function (datas) {
                $("#Embed").html(datas);
            });
        });

        $("#SampleLogin-SetSkipWorkflow").click(function () {
            if (SampleLogin_Id.length == 0) {
                return false;
            }

            $("#SAMPLE-SampleLogin-Modal-Title").text("流程配置");

            $("#SAMPLE-SampleLogin-Modal").modal({
                backdrop: 'static',
                keyboard: false
            });

            $.post("SetSkipWorkflow", {
                SetSampleLogin: "True",
                SampleDefefinitionId: SampleLogin_Id,
                ModalID: "SAMPLE-SampleLogin-Modal"
            }, function (datas) {
                $("#Embed").html(datas);
            });
        });

        $("#SampleLogin-StartSample").click(function () {
            var ids = GetSelectItems();
            if (ids.length == 0) {
                return false;
            }

            $.post("StartSampleLogin", {
                Ids: ids
            }, function (data) {
                if (data.indexOf("成功") >= 0) {
                    var nids = ids.split(',');
                    nids.forEach(function(value,index,nids){
                        $.post("GetSampleLogin", {
                            Id: value
                        }, function (data) {
                            var row = $("#SampleLogin-Table").bootstrapTable('getRowByUniqueId', value); // 获得行数据
                            row.sampleId = data.sampleId;
                            row.sampleNumber = data.sampleNumber;
                            row.batchId = data.batchId;
                            $('#SampleLogin-Table').bootstrapTable('updateByUniqueId', row);  // 更新行数据
                            $('td label').css("margin-bottom", "0px"); // 设置数据行选择控件的样式
                        });
                    });
                } else {
                    alert(data);
                }
            });
        });

        $('#SAMPLE-SampleLogin-Modal').on('hidden.bs.modal', function (event) {
            if (event.target == this) {
                if (SampleLogin_refrens == 1) {
                    LoadSampleLogin();
                } else {
                    LoadAnalyte(SampleLogin_Id);
                    LoadTestDefinition(SampleLogin_Id);
                    LoadSpecCollection(SampleLogin_Id);
                }

                if (SampleLogin_Id.length > 0) {
                    $("#SampleLogin-Table").find("tbody").find("tr").each(function () {
                        if ($(this).attr("data-uniqueid") == SampleLogin_Id)
                            $(this).addClass("changeblueColor");
                    });
                }
            }
        });

        $("#SampleLogin-tabAnalyte-addAnalyte").click(function () {
            if (SampleLogin_Id.length == 0) {
                alert("请先选择需要添加关系的样品！");
                return;
            }

            $("#SAMPLE-SampleLogin-Modal-Title").text("添加关联分析项");

            $("#SAMPLE-SampleLogin-Modal").modal({
                backdrop: 'static',
                keyboard: false
            });

            $.post("AddSampleLoginAnalyte", {
                SampleLoginId: SampleLogin_Id,
                ModalID: "SAMPLE-SampleLogin-Modal"
            }, function (datas) {
                $("#Embed").html(datas);
            });
        });

        $("#SampleLogin-tabAnalyte-delAnalyte").click(function () {
            if (SampleLogin_AnalyteId.length == 0) {
                alert("请先选择需要删除关系的分析项！");
                return;
            }

            $("#SAMPLE-SampleLogin-Modal-Title").text("删除关联分析项");

            $("#SampleLogin-DelAnalyteRelation-modal").modal({
                backdrop: 'static',
                keyboard: false
            });
        });

        $("#SampleLogin-tabTestDefinition-addTD").click(function () {
            if (SampleLogin_Id.length == 0) {
                alert("请先选择需要添加关系的样品！");
                return;
            }

            $("#SAMPLE-SampleLogin-Modal-Title").text("添加关联测试");

            $("#SAMPLE-SampleLogin-Modal").modal({
                backdrop: 'static',
                keyboard: false
            });

            $.post("AddRelationSDAndTestDefinition", {
                SampleLoginId: SampleLogin_Id,
                ModalID: "SAMPLE-SampleLogin-Modal"
            }, function (datas) {
                $("#Embed").html(datas);
            });
        });

        $("#SampleLogin-tabTestDefinition-delTD").click(function () {
            if (SampleLogin_TestDefinitonId.length == 0) {
                alert("请先选择需要删除关系的测试！");
                return;
            }

            $("#SAMPLE-SampleLogin-Modal-Title").text("删除关联测试项");

            $("#SampleLogin-DelTestDefinitionRelation-modal").modal({
                backdrop: 'static',
                keyboard: false
            });
        });

        $("#SampleLogin-tabTestDefinition-delAna").click(function () {
            if (SampleLogin_TD_AnalyteId.length == 0) {
                alert("请先选择需要删除的测试中的分析项！");
                return;
            }

            $("#SAMPLE-SampleLogin-Modal-Title").text("删除测试中的分析项");

            $("#SampleLogin-DelTestDefinitionRelationAna-modal").modal({
                backdrop: 'static',
                keyboard: false
            });
        });

        $("#SampleLogin-tabSpecCollection-addSpc").click(function () {
            if (SampleLogin_Id.length == 0) {
                alert("请先选择需要添加关系的样品！");
                return;
            }

            $("#SAMPLE-SampleLogin-Modal-Title").text("添加关联指标集");

            $("#SAMPLE-SampleLogin-Modal").modal({
                backdrop: 'static',
                keyboard: false
            });

            $.post("AddSampleSpecCollection", {
                SampleLoginId: SampleLogin_Id,
                ModalID: "SAMPLE-SampleLogin-Modal"
            }, function (datas) {
                $("#Embed").html(datas);
            });
        });

        $("#SampleLogin-tabSpecCollection-delSpc").click(function () {
            if (SampleLogin_SpecCollectionId.length == 0) {
                alert("请先选择需要删除的指标集！");
                return;
            }

            $("#SAMPLE-SampleLogin-Modal-Title").text("删除关联指标集");

            $("#SampleLogin-DelSpecCollection-modal").modal({
                backdrop: 'static',
                keyboard: false
            });
        });

        $("#SampleLogin-DelSpecCollection-modal-delete").click(function () {
            $.post("DelteSampleLoginRelationById", {
                Id: SampleLogin_SpecCollectionId
            }, function (data) {
                if (data.indexOf("成功") >= 0) {
                    $('#SampleDefinition-tabSpecList').bootstrapTable('removeByUniqueId', SampleLogin_SpecCollectionId);  // 删除指定的行
                    SampleLogin_SpecCollectionId = "";  // 删除行后，将这个值置空，否则直接编辑信息就会报错。
                } else {
                    alert(data);
                }
            });

            $("#SampleLogin-DelSpecCollection-modal").modal('hide');
        });

        $("#SampleLogin-DelTestDefinitionRelation-modal-delete").click(function () {
            $.post("DelteSampleLoginTestById", {
                Id: SampleLogin_TestDefinitonId
            }, function (data) {
                if (data.indexOf("成功") >= 0) {
                    $('#SampleLogin-tabTestDefinition-TD').bootstrapTable('removeByUniqueId', SampleLogin_TestDefinitonId);
                    SampleLogin_TestDefinitonId = "";  // 删除行后，将这个值置空，否则直接编辑信息就会报错。
                } else {
                    alert(data);
                }
            });

            $("#SampleLogin-DelTestDefinitionRelation-modal").modal('hide');
        });

        $("#SampleLogin-DelTestDefinitionRelationAna-modal-delete").click(function () {
            $.post("DelteSampleLoginRelationById", {
                Id: SampleLogin_TD_AnalyteId
            }, function (data) {
                if (data.indexOf("成功") >= 0) {
                    SampleLogin_TD_AnalyteId = "";  // 删除行后，将这个值置空，否则继续删除会报错。
                } else {
                    alert(data);
                }
            });

            $("#SampleLogin-DelTestDefinitionRelationAna-modal").modal('hide');
        });

        $("#SampleLogin-bPrintlab").click(function () {
            var ids = GetSelectItems("SampleLogin-Table");
            if (ids == null) {
                return;
            }

            $("#SampleLogin-PrintLab-Title").text("选择样品标签");

            $("#SampleLogin-PrintLab").modal({
                backdrop: 'static',
                keyboard: false
            });

            $.post("SelectSamplingLab", {
                Ids: ids,
                LabType: "Sampling",
                ModalID: "SampleLogin-PrintLab"
            }, function (datas) {
                $("#SampleLogin-PrintLab-Embed").html(datas);
            });
        });

        $(".tabButton").hover(
            function () {
                $('.tabButton').addClass('tab-first-mouse'); // 鼠标进入时绑定样式
            },
            function () {
                $('.tabButton').removeClass('tab-first-mouse'); // 鼠标进入时绑定样式
        });

        $("#li-tabAnalyte").hover(
            function () {
                if ($(this).attr("class").indexOf('tab-first-active') > 0) {
                    $(this).addClass('tab-enter-mouse');
                }
                if ($(this).attr("class").indexOf('tab-first-noactive') > 0) {
                    $(this).removeClass('tab-first-noactive');
                    $(this).addClass('tab-first-noactive-mouse');
                }
            },
            function () {
                $(this).removeClass('tab-enter-mouse');
                $(this).removeClass('tab-first-noactive-mouse');

                if ($(this).attr("data-active") == 'true') {
                    $(this).addClass('tab-first-active');
                }
                if ($(this).attr("data-active") == 'false') {
                    $(this).addClass('tab-first-noactive');
                }
            });

        $("#li-tabTestDefinition").hover(
            function () {
                if ($(this).attr("class").indexOf('tab-other-active') > 0) {
                    $(this).addClass('tab-enter-mouse');
                }
                if ($(this).attr("class").indexOf('tab-other-noactive') > 0) {
                    $(this).removeClass('tab-other-noactive');
                    $(this).addClass('tab-other-noactive-mouse');
                }
            },
            function () {
                $(this).removeClass('tab-enter-mouse');
                $(this).removeClass('tab-other-noactive-mouse');

                if ($(this).attr("data-active") == 'true') {
                    $(this).addClass('tab-other-active');
                }
                if ($(this).attr("data-active") == 'false') {
                    $(this).addClass('tab-other-noactive');
                }
            });

        $("#a-tabAnalyte").click(function () {
            if ($("#li-tabTestDefinition").attr("class").indexOf('tab-other-active') > 0) {
                $("#li-tabTestDefinition").removeClass('tab-other-active');
                $("#li-tabTestDefinition").addClass('tab-other-noactive');
            }
            if ($("#li-tabSpecCollection").attr("class").indexOf('tab-other-active') > 0) {
                $("#li-tabSpecCollection").removeClass('tab-other-active');
                $("#li-tabSpecCollection").addClass('tab-other-noactive');
            }

            $("#li-tabAnalyte").attr("data-active", true);
            $("#li-tabTestDefinition").attr("data-active", false);
            $("#li-tabSpecCollection").attr("data-active", false);
        });

        $("#a-tabTestDefinition").click(function () {
            if ($("#li-tabAnalyte").attr("class").indexOf('tab-first-active') > 0) {
                $("#li-tabAnalyte").removeClass('tab-first-active');
                $("#li-tabAnalyte").addClass('tab-first-noactive');
            }
            if ($("#li-tabSpecCollection").attr("class").indexOf('tab-other-active') > 0) {
                $("#li-tabSpecCollection").removeClass('tab-other-active');
                $("#li-tabSpecCollection").addClass('tab-other-noactive');
            }

            $("#li-tabTestDefinition").attr("data-active", true);
            $("#li-tabAnalyte").attr("data-active", false);
            $("#li-tabSpecCollection").attr("data-active", false);
        });

        $("#li-tabTestSpecCollection").hover(
            function () {
                if ($(this).attr("class").indexOf('tab-first-active') > 0) {
                    $(this).addClass('tab-enter-mouse');
                }
                if ($(this).attr("class").indexOf('tab-first-noactive') > 0) {
                    $(this).removeClass('tab-first-noactive');
                    $(this).addClass('tab-first-noactive-mouse');
                }
            },
            function () {
                $(this).removeClass('tab-enter-mouse');
                $(this).removeClass('tab-first-noactive-mouse');

                if ($(this).attr("data-active") == 'true') {
                    $(this).addClass('tab-first-active');
                }
                if ($(this).attr("data-active") == 'false') {
                    $(this).addClass('tab-first-noactive');
                }
            });

        $("#li-tabTestMethod").hover(
            function () {
                if ($(this).attr("class").indexOf('tab-other-active') > 0) {
                    $(this).addClass('tab-enter-mouse');
                }
                if ($(this).attr("class").indexOf('tab-other-noactive') > 0) {
                    $(this).removeClass('tab-other-noactive');
                    $(this).addClass('tab-other-noactive-mouse');
                }
            },
            function () {
                $(this).removeClass('tab-enter-mouse');
                $(this).removeClass('tab-other-noactive-mouse');

                if ($(this).attr("data-active") == 'true') {
                    $(this).addClass('tab-other-active');
                }
                if ($(this).attr("data-active") == 'false') {
                    $(this).addClass('tab-other-noactive');
                }
            });

        $("#li-tabSpecCollection").hover(
            function () {
                if ($(this).attr("class").indexOf('tab-other-active') > 0) {
                    $(this).addClass('tab-enter-mouse');
                }
                if ($(this).attr("class").indexOf('tab-other-noactive') > 0) {
                    $(this).removeClass('tab-other-noactive');
                    $(this).addClass('tab-other-noactive-mouse');
                }
            },
            function () {
                $(this).removeClass('tab-enter-mouse');
                $(this).removeClass('tab-other-noactive-mouse');

                if ($(this).attr("data-active") == 'true') {
                    $(this).addClass('tab-other-active');
                }
                if ($(this).attr("data-active") == 'false') {
                    $(this).addClass('tab-other-noactive');
                }
            });

        $("#a-tabTestSpecCollection").click(function () {
            if ($("#li-tabTestMethod").attr("class").indexOf('tab-other-active') > 0) {
                $("#li-tabTestMethod").removeClass('tab-other-active');
                $("#li-tabTestMethod").addClass('tab-other-noactive');
            }

            $("#li-tabTestSpecCollection").attr("data-active", true);
            $("#li-tabTestMethod").attr("data-active", false);
            $("#li-tabSpecCollection").attr("data-active", false);
        });

        $("#a-tabTestMethod").click(function () {
            if ($("#li-tabTestSpecCollection").attr("class").indexOf('tab-first-active') > 0) {
                $("#li-tabTestSpecCollection").removeClass('tab-first-active');
                $("#li-tabTestSpecCollection").addClass('tab-first-noactive');
            }

            $("#li-tabTestMethod").attr("data-active", true);
            $("#li-tabTestSpecCollection").attr("data-active", false);
            $("#li-tabSpecCollection").attr("data-active", false);
        });

        $("#a-tabSpecCollection").click(function () {
            if ($("#li-tabAnalyte").attr("class").indexOf('tab-first-active') > 0) {
                $("#li-tabAnalyte").removeClass('tab-first-active');
                $("#li-tabAnalyte").addClass('tab-first-noactive');
            }
            if ($("#li-tabTestDefinition").attr("class").indexOf('tab-other-active') > 0) {
                $("#li-tabTestDefinition").removeClass('tab-other-active');
                $("#li-tabTestDefinition").addClass('tab-other-noactive');
            }

            $("#li-tabSpecCollection").attr("data-active", true);
            $("#li-tabAnalyte").attr("data-active", false);
            $("#li-tabTestDefinition").attr("data-active", false);
        });

    </script>
}
